﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="~/js/lib/ztree/css/demo.css" rel="stylesheet" />
    <link href="~/js/lib/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <script src="~/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="~/js/ztree/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript">
		var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },view: {
                fontCss: getFont
            }
            //, callback: {
            //    onClick: onClick
            //}
        }; 
        var zNodes = [];
        $.ajax({
            type: 'post',
            url: '/Home/GetMenuList',
            dataType: 'json',
            success: function (data) {
                for (var i = 0, l = data.length; i < l; i++) {
                    if (data[i].menuUrl === "" || data[i].menuUrl === null) {
                        zNodes.push({ id: data[i].menuId, pId: data[i].menuParentId, name: data[i].menuName, open: true})
                    }
                    else {
                        zNodes.push({ id: data[i].menuId, pId: data[i].menuParentId, name: data[i].menuName, url: data[i].menuUrl + "?MenuId=" + data[i].menuId + "&RoleId=" + $("#RoleUserId").val(), target: "rightFrame" })
                    }
                }
                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            }
        });
        function getFont(treeId, node) {
            return node.font ? node.font : {};
        }

        // 点击事件
        //function onClick(event, treeId, treeNode, clickFlag) {
        //    $.ajax({
        //        url: "/Button/ButtonRole",
        //        type: 'post',
        //        data: { MenuId: treeNode.id },
        //        dataType: "json",
        //        async: "false",
        //        success: function (data) {

        //        }
        //    });
        //}
    </script>


</head>
<body style="background:#fff3e1;">
    <div style="background:url(../images/lefttop.gif) repeat-x;height:40px;color:#fff;font-size:14px;line-height:40px;text-align:center">菜单</div>
    <dl class="leftmenu">
        <dd>
            <ul id="treeDemo" class="ztree" style="height:100%;background-color:#F9ECD9;width:100%;"></ul>
        </dd>
    </dl>
    <input id="RoleUserId" type="hidden" value="@ViewData["RoleUserId"]" />
</body>
</html>